<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box">
        <a href="/qwer">首页</a>
        <a href="/asdf">第二页</a>
        <a href="/zxcv">第三页</a>
    </div>
    <div class="conment"></div>
</body>

</html>
<script>
    var as = document.querySelectorAll('a')
    as.forEach((item) => {
        item.onclick = function (e) {
            e.preventDefault()
            history.pushState({}, '', this.href);
            console.log(location);
            switch (location.pathname) {
            case '/qwer': home_page(); break;
            case '/asdf': service_page(); break;
            case '/zxcv': mine_page(); break;
        }
        }
     
        
    })
    function home_page() {
        document.querySelector('.conment').innerHTML = '首页的内容';
    }
  
    function service_page() {
        document.querySelector('.conment').innerHTML = '服务的内容';
    }

    function mine_page() {
        document.querySelector('.conment').innerHTML = '个人中心的内容';
    }
</script>